const fs = require('fs')

const filePath = 'D:/influxdb-data.txt'
const total = 100000;

const serverArr = [1, 2, 3, 4, 5, 6, 7, 8]
const regionArr = ['bj', 'sh', 'nb', 'cq', 'hz']
const percentArr = [26.79, 30.13, 40.88, 90.22, 66.23, 16.50, 15.11, 12.88, 39.55, 50.76, 55.43, 58.88, 33.33, 22.22, 11.11]
const valueArr = [2151672, 3068883, 346290, 554182]
let startTime = 1679299429085

function createInfluxdbData() {
    for (let i = 0; i < total; i++) {
        let tmp = `mem_usage,hostname=${serverArr[i%serverArr.length]},region=${regionArr[i%regionArr.length]} percent=${percentArr[i%percentArr.length]},value=${valueArr[i%valueArr.length]} `
        startTime += 100
        let time = startTime + '000000'
        let finalData = tmp  + time + '\n'
        fs.writeFileSync(filePath, finalData, {flag: 'a'})
    }
}

createInfluxdbData();